package dao;

import entity.Check_inRecords;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.time.Duration;
import java.util.ArrayList;

public class GetMembers {
    public static ArrayList<Check_inRecords> getMeetingMembers(String meetingId){
        ArrayList<Check_inRecords> res=new ArrayList<>();
        String sql="select account.id,name,check_inTime,duration from account right join attendence on account.id=attendence.account_id where meeting_id=?";
        try {
            Connection conn=DataBaseConnect.getConnection();
            PreparedStatement pstmt=conn.prepareStatement(sql);
            pstmt.setString(1,meetingId);
            ResultSet rs=pstmt.executeQuery();
            while (rs.next()){
                res.add(new Check_inRecords(rs.getString(1),rs.getString(2),
                        rs.getTimestamp(3),Duration.ofSeconds(rs.getLong(4))));
            }
        }catch (Exception e){
            System.out.println("获取用户信息error");
            e.printStackTrace();
        }
        return res;
    }
}
